package cn.bocweb.spinning.model.Imp;

import android.util.Pair;

import com.google.gson.Gson;
import com.squareup.okhttp.Request;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.bocweb.spinning.model.Bean.*;
import cn.bocweb.spinning.model.Model;
import cn.bocweb.spinning.net.myOkhttp.callback.ResultCallback;
import cn.bocweb.spinning.net.myOkhttp.request.OkHttpRequest;
import cn.bocweb.spinning.util.DeviceUtil;
import de.greenrobot.event.EventBus;
import retrofit.Call;
import retrofit.Callback;
import retrofit.Response;
import retrofit.Retrofit;

/**
 * Created by chenchangxing on 16/1/7.
 */
public class UserModelImp extends BaseModelImp implements Model {

    @Override
    public void regVerify(String timeline, String sign, String phone) {
        Call call = mServer.regVerify(timeline, sign, phone);
        call.enqueue(new MyCallback<RegVerifyBean>());
    }

    @Override
    public void sign(String timeline, String sign, String userid) {
        Call call = mServer.sign(timeline, sign, userid);
        call.enqueue(new MyCallback<SignBean>());
    }

    @Override
    public void login(String timeline, String sign, String phone, String pwd) {
        Call call = mServer.login(timeline, sign, phone, pwd);
        call.enqueue(new MyCallback<UserBean>());
    }

    @Override
    public void changePwd(String timeline, String sign, String userid, String pwd, String newpwd, String confirmpwd) {
        Call call = mServer.changePwd(timeline, sign, userid, pwd, newpwd, confirmpwd);
        call.enqueue(new MyCallback<ChangePwdBean>());
    }

    @Override
    public void reg(String timeline, String sign, String nickname, String phone, String verify, String pwd, String confirmpwd) {
        Call call = mServer.reg(timeline, sign, nickname, phone, verify, pwd, confirmpwd);
        call.enqueue(new MyCallback<UserBean>());
    }

    @Override
    public void findVerify(String timeline, String sign, String phone) {
        Call call = mServer.findVerify(timeline, sign, phone);
        call.enqueue(new MyCallback<FindVerifyBean>());
    }

    @Override
    public void findPwd(String timeline, String sign, String phone, String pwd, String confirmpwd, String verify) {
        Call call = mServer.findPwd(timeline, sign, phone, pwd, confirmpwd, verify);
        call.enqueue(new MyCallback<FindPwdBean>());
    }

    @Override
    public void updateInfo(String timeline, String sign, String userid, String nickname, String realname, String company, String position, String tel, String gender, String address, String code, File file, String filename, String device) {

        Map<String, String> params = new HashMap<>();
        params.put("timeline", timeline);
        params.put("sign", sign);
        params.put("userid", userid);
        params.put("nickname", nickname);
        params.put("realname", realname);
        params.put("company", company);
        params.put("position", position);
        params.put("gender", gender);
        params.put("tel", tel);
        params.put("address", address);
        params.put("code", code);
        params.put("device", device);


        if (file != null) {
            new OkHttpRequest.Builder()
                    .url("http://115.29.198.151/fzapp/index.php/user/updateInfo")
                    .params(params)
                    .files(new Pair<>("uthumb", file))
                    .upload(new ResultCallback<String>() {

                        @Override
                        public void onError(com.squareup.okhttp.Request request, Exception e) {
                            ErrorBean bean = new ErrorBean();
                            bean.setErrorMsg("网络超时错误");
                            EventBus.getDefault().post(bean);
                        }

                        @Override
                        public void onResponse(String response) {
                            UpdateInfoBean bean = new Gson().fromJson(response, UpdateInfoBean.class);
                            EventBus.getDefault().post(bean);
                        }
                    });
        } else {
            new OkHttpRequest.Builder()
                    .url("http://115.29.198.151/fzapp/index.php/user/updateInfo")
                    .params(params)
                    .upload(new ResultCallback<String>() {

                        @Override
                        public void onError(com.squareup.okhttp.Request request, Exception e) {
                            ErrorBean bean = new ErrorBean();
                            bean.setErrorMsg("网络超时错误");
                            EventBus.getDefault().post(bean);
                        }

                        @Override
                        public void onResponse(String response) {
                            UpdateInfoBean bean = new Gson().fromJson(response, UpdateInfoBean.class);
                            EventBus.getDefault().post(bean);
                        }
                    });
        }
    }

    @Override
    public void getCtype(String timeline, String sign) {
        Call call = mServer.getCtype(timeline, sign);
        call.enqueue(new MyCallback<GetCtypeBean>());
    }

    @Override
    public void getFlag(String timeline, String sign, String ctype) {
        Call call = mServer.getFlag(timeline, sign, ctype);
        call.enqueue(new MyCallback<GetFlagBean>());
    }

    @Override
    public void getIhome(String timeline, String sign, String ctype, String page, String page_size, String search) {
        Call call = mServer .getIhome(timeline, sign, ctype, page, page_size, search);
        call.enqueue(new MyCallback<GetIhomeBean>());
    }

    @Override
    public void libList(String timeline, String sign) {
        Call call = mServer.libList(timeline, sign);
        call.enqueue(new MyCallback<LibListBean>());
    }

    @Override
    public void getAdd(String timeline, String sign, String id, String userid) {
        Call call = mServer.getAdd(timeline, sign, id, userid);
        call.enqueue(new MyCallback<GetAddBean>());
    }

    @Override
    public void getCommentTotal(String timeline, String sign, String id) {
        Call call = mServer.getCommentTotal(timeline, sign, id);
        call.enqueue(new MyCallback<GetCommentTotalBean>());
    }

    @Override
    public void getCommentDetail(String timeline, String sign, String id, String page, String page_size) {
        Call call = mServer.getCommentDetail(timeline, sign, id, page, page_size);
        call.enqueue(new MyCallback<GetCommentDetailBean>());
    }

    @Override
    public void insertComment(String timeline, String sign, String id, String userid, String content) {
        Call call = mServer.insertComment(timeline, sign, id, userid, content);
        call.enqueue(new MyCallback<InsertCommentBean>());
    }

    @Override
    public void getMyComment(String timeline, String sign, String userid, String page, String page_size) {
        Call call = mServer.getMyComment(timeline, sign, userid, page, page_size);
        call.enqueue(new MyCallback<GetMyCommentBean>());
    }

    @Override
    public void addFavorites(String timeline, String sign, String aid, String userid) {
        Call call = mServer.addFavorites(timeline, sign, aid, userid);
        call.enqueue(new MyCallback<AddFavoritesBean>());
    }

    @Override
    public void startExam(String timeline, String sign, String userid, String libtype) {
        Call call = mServer.startExam(timeline, sign, userid, libtype);
        call.enqueue(new MyCallback<StartExamBean>());
    }

    @Override
    public void finishExam(String timeline, String sign, String testid, String userid, String spend_time, String detail) {
        Call call = mServer.finishExam(timeline, sign, testid, userid, spend_time, detail);
        call.enqueue(new MyCallback<FinishExamBean>());
    }

    @Override
    public void testRecord(String timeline, String sign, String userid, String libtype, String pagecount, String page) {
        Call call = mServer.testRecord(timeline, sign, userid, libtype, pagecount, page);
        call.enqueue(new MyCallback<TestRecordBean>());
    }

    @Override
    public void testDetail(String timeline, String sign, String userid, String testid) {
        Call call = mServer.testDetail(timeline, sign, userid, testid);
        call.enqueue(new MyCallback<TestDetailBean>());
    }

    @Override
    public void testKeys(String timeline, String sign, String userid, String testid) {
        Call call = mServer.testKeys(timeline, sign, userid, testid);
        call.enqueue(new MyCallback<TestKeysBean>());
    }

    @Override
    public void testErrors(String timeline, String sign, String userid, String testid) {
        Call call = mServer.testErrors(timeline, sign, userid, testid);
        call.enqueue(new MyCallback<TestKeysBean>());
    }

    @Override
    public void trainRandomStart(String timeline, String sign, String count, String libtype, String userid, String init) {
        Call<TrainRandomStartBean> call = mServer.trainRandomStart(timeline, sign, count, libtype, userid, init);
        call.enqueue(new MyCallback<TrainRandomStartBean>());
    }

    @Override
    public void trainRandom(String timeline, String sign, String count, String libtype, String userid, String init) {
        Call<TrainRandomBean> call = mServer.trainRandom(timeline, sign, count, libtype, userid, init);
        call.enqueue(new MyCallback<TrainRandomBean>());
    }

    @Override
    public void trainRandomKeys(String timeline, String sign, String count, String id, String ttype, String libtype, String isright, String choose, String userid) {
        Call<TrainRandomKeysBean> call = mServer.trainRandomKeys(timeline, sign, count, id, ttype, libtype, isright, choose, userid);
        call.enqueue(new MyCallback<TrainRandomKeysBean>());
    }

    @Override
    public void getCollectFavorites(String timeline, String sign, String userid, String page, String page_size) {
        Call call = mServer.getCollectFavorites(timeline, sign, userid, page, page_size);
        call.enqueue(new MyCallback<GetCollectFavoritesBean>());
    }

    @Override
    public void forumMyCollect(String timeline, String sign, String page, String pagecount, String userid) {
        Call call = mServer.forumMyCollect(timeline, sign, page, pagecount, userid);
        call.enqueue(new MyCallback<ForumMyCollectBean>());
    }

    @Override
    public void errorTrainStart(String timeline, String sign, String count, String libtype, String userid) {
        Call call = mServer.errorTrainStart(timeline, sign, count, libtype, userid);
        call.enqueue(new MyCallback<TrainRandomStartBean>());
    }

    @Override
    public void errorTrain(String timeline, String sign, String count, String libtype, String userid) {
        Call call = mServer.errorTrain(timeline, sign, count, libtype, userid);
        call.enqueue(new MyCallback<TrainRandomBean>());
    }

    @Override
    public void errorKeys(String timeline, String sign, String count, String id, String ttype, String libtype, String isright, String choose, String userid) {
        Call call = mServer.errorKeys(timeline, sign, count, id, ttype, libtype, isright, choose, userid);
        call.enqueue(new MyCallback<TrainRandomKeysBean>());
    }

    @Override
    public void testCollect(String timeline, String sign, String id, String ttype, String libtype, String userid, String isright, String choose) {
        Call call = mServer.testCollect(timeline, sign, id, ttype, libtype, userid, isright, choose);
        call.enqueue(new MyCallback<TestCollectBean>());
    }

    @Override
    public void hardTrainStart(String timeline, String sign, String count, String libtype, String userid) {
        Call call = mServer.hardTrainStart(timeline, sign, count, libtype, userid);
        call.enqueue(new MyCallback<TrainRandomStartBean>());
    }

    @Override
    public void hardTrain(String timeline, String sign, String count, String libtype, String userid) {
        Call call = mServer.hardTrain(timeline, sign, count, libtype, userid);
        call.enqueue(new MyCallback<TrainRandomBean>());
    }

    @Override
    public void hardKeys(String timeline, String sign, String count, String id, String ttype, String libtype, String isright, String userid) {
        Call call = mServer.hardKeys(timeline, sign, count, id, ttype, libtype, isright, userid);
        call.enqueue(new MyCallback<TrainRandomKeysBean>());
    }

    @Override
    public void collectList(String timeline, String sign, String libtype, String userid, String pagecount, String page) {
        Call call = mServer.collectList(timeline, sign, libtype, userid, pagecount, page);
        call.enqueue(new MyCallback<CollectListBean>());
    }

    @Override
    public void collectQuestion(String timeline, String sign, String count, String userid, String libtype) {
        Call call = mServer.collectQuestion(timeline, sign, count, userid, libtype);
        call.enqueue(new MyCallback<MyTestCollectBean>());
    }

    @Override
    public void collectRemove(String timeline, String sign, String libtype, String userid, String type, String count, String ttype) {
        Call call = mServer.collectRemove(timeline, sign, libtype, userid, type, count, ttype);
        call.enqueue(new MyCallback<CollectRemoveBean>());
    }

    @Override
    public void sequenceTest(String timeline, String sign, String count, String libtype, String userid) {
        Call call = mServer.sequenceTest(timeline, sign, count, libtype, userid);
        call.enqueue(new MyCallback<SequenceTestBean>());
    }

    @Override
    public void sequenceKeys(String timeline, String sign, String count, String id, String ttype, String libtype, String isright, String choose, String userid) {
        Call call = mServer.sequenceKeys(timeline, sign, count, id, ttype, libtype, isright, choose, userid);
        call.enqueue(new MyCallback<SequenceKeysBean>());
    }

    @Override
    public void sequenceList(String timeline, String sign, String libtype, String userid, String pagecount, String page) {
        Call call = mServer.sequenceList(timeline, sign, libtype, userid, pagecount, page);
        call.enqueue(new MyCallback<SequenceListBean>());
    }

    @Override
    public void getMsg(String timeline, String sign, String userid, String type, String pagecount, String page) {
        Call call = mServer.getMsg(timeline, sign, userid, type, pagecount, page);
        call.enqueue(new MyCallback<GetMsgBean>());
    }

    @Override
    public void feedBack(String timeline, String sign, String userid, String question) {
        Call call = mServer.feedback(timeline, sign, userid, question);
        call.enqueue(new MyCallback<FeedbackBean>());
    }

    @Override
    public void myClass(String timeline, String sign, String userid, String libtype) {
        Call call = mServer.myClass(timeline, sign, userid, libtype);
        call.enqueue(new MyCallback<MyClassBean>());
    }

    @Override
    public void delExamrecord(String timeline, String sign, String libtype, String userid, String type, String id) {
        Call call = mServer.delExamrecord(timeline, sign, libtype, userid, type, id);
        call.enqueue(new MyCallback<DelExamrecordBean>());
    }

    @Override
    public void testRank(String timeline, String sign, String libtype, String userid, String interval, String pagecount, String page) {
        Call call = mServer.testRank(timeline, sign, libtype, userid, interval, pagecount, page);
        call.enqueue(new MyCallback<TestRankBean>());
    }

    @Override
    public void collectKey(String timeline, String sign, String count, String userid, String libtype, String choose, String isright) {
        Call call = mServer.collectKey(timeline, sign, count, userid, libtype, choose, isright);
        call.enqueue(new MyCallback<CollectKeyBean>());
    }

    @Override
    public void myFeedback(String timeline, String sign, String userid) {
        Call call = mServer.myFeedback(timeline, sign, userid);
        call.enqueue(new MyCallback<MyFeedBackBean>());
    }

    @Override
    public void newFeedback(String timeline, String sign, String userid) {
        Call call = mServer.newFeedback(timeline, sign, userid);
        call.enqueue(new MyCallback<NewFeedbackBean>());
    }

    @Override
    public void helpList(String timeline, String sign, String pagecount, String page) {
        Call call = mServer.helpList(timeline, sign, pagecount, page);
        call.enqueue(new MyCallback<HelpListBean>());
    }

    @Override
    public void helpAddress(String timeline, String sign, String id) {
        Call call = mServer.helpAddress(timeline, sign, id);
        call.enqueue(new MyCallback<HelpAddressBean>());
    }

    @Override
    public void delFavorites(String timeline, String sign, String aid, String userid) {
        Call call = mServer.delFavorites(timeline, sign, aid, userid);
        call.enqueue(new MyCallback<DelFavoritesBean>());
    }

    @Override
    public void delComment(String timeline, String sign, String id, String userid) {
        Call call = mServer.delComment(timeline, sign, id, userid);
        call.enqueue(new MyCallback<DelCommentBean>());
    }

    @Override
    public void sequenceSync(String timeline, String sign, String libtype, String userid, String data) {
        Call call = mServer.sequenceSync(timeline, sign, libtype, userid, data);
        call.enqueue(new MyCallback<SequenceSyncBean>());
    }

    @Override
    public void indexSlider(String timeline, String sign) {
        Call call = mServer.indexSlider(timeline, sign);
        call.enqueue(new MyCallback<IndexSliderBean>());
    }

    @Override
    public void registerDoc(String timeline, String sign) {
        Call call = mServer.registerDoc(timeline, sign);
        call.enqueue(new MyCallback<RegisterDocBean>());
    }

    @Override
    public void getCompanyList1(String timeline, String sign, String pagecount, String page, String userid) {
        Call call = mServer.getCompanyList1(timeline, sign, pagecount, page, userid);
        call.enqueue(new MyCallback<CompanyList1Bean>());
    }

    @Override
    public void getCompanyIntro(String timeline, String sign, String id) {
        Call call = mServer.getCompanyIntro(timeline, sign, id);
        call.enqueue(new MyCallback<CompanyIntroBean>());
    }

    @Override
    public void getCompanyCerify(String timeline, String sign, String id) {
        Call call = mServer.getCompanyCerify(timeline, DeviceUtil.getSign(timeline), id);
        call.enqueue(new MyCallback<CompanyCerifyBean>());
    }

    @Override
    public void getCompanyContact(String timeline, String sign, String id) {
        Call call = mServer.getCompanyContact(timeline, DeviceUtil.getSign(timeline), id);
        call.enqueue(new MyCallback<CompanyContactBean>());
    }

    @Override
    public void getCompanyCollect(String timeline, String sign, String id, String userid, String type) {
        Call call = mServer.getCompanyCollect(timeline, sign, id, userid, type);
        call.enqueue(new MyCallback<CompanyCollectBean>());
    }

    @Override
    public void getCollectCompany(String timeline, String sign, String userid, String pagecount, String page) {
        Call call = mServer.getCollectCompany(timeline, sign, userid, pagecount, page);
        call.enqueue(new MyCallback<CollectCompanyBean>());
    }

    @Override
    public void getCompanySearchCat(String timeline, String sign) {
        Call call = mServer.getCompanySearchCat(timeline, sign);
        call.enqueue(new MyCallback<SearchCatBean>());
    }

    @Override
    public void getCompanySearchLocation(String timeline, String sign) {
        Call call = mServer.getCompanySearchLocation(timeline, sign);
        call.enqueue(new MyCallback<CompanySearchLocationBean>());
    }

    @Override
    public void getProductList(String timeline, String sign, String pagecount, String page, String userid) {
        Call call = mServer.getProductList(timeline, sign, pagecount, page, userid);
        call.enqueue(new MyCallback<Product1Bean>());
    }

    @Override
    public void collectProduct(String timeline, String sign, String id, String userid, String type) {
        Call call = mServer.collectProduct(timeline, sign, id, userid, type);
        call.enqueue(new MyCallback<CollectProductBean>());
    }

    @Override
    public void getProductDetail(String timeline, String sign, String id) {
        Call call = mServer.getProductDetail(timeline, sign, id);
        call.enqueue(new MyCallback<ProductDetailBean>());
    }

    @Override
    public void getProductCollectList(String timeline, String sign, String userid, String pagecount, String page) {
        Call call = mServer.getProductCollectList(timeline, sign, userid, pagecount, page);
        call.enqueue(new MyCallback<ProductCollectBean>());
    }

    @Override
    public void getProductSearchCat(String timeline, String sign) {
        Call call = mServer.getProductSearchCat(timeline, sign);
        call.enqueue(new MyCallback<SearchCatBean>());
    }

    @Override
    public void forunGetForun(String timeline, String sign) {
        Call call = mServer.forunGetForun(timeline, sign);
        call.enqueue(new MyCallback<ForunGetCatBean>());
    }

    @Override
    public void sendForun(String timeline, String sign, String userid, String cat, String title, String content, List<File> files) {
        Map<String, String> params = new HashMap<>();
        params.put("timeline", timeline);
        params.put("sign", sign);
        params.put("userid", userid);
        params.put("cat", cat);
        params.put("title", title);
        params.put("content", content);

        Pair<String, File>[] pairs;

        switch (files.size()) {
            case 0:
                new OkHttpRequest.Builder()
                        .url("http://115.29.198.151/fzapp/index.php/forumapp/publish")
                        .params(params)
                        .upload(new ResultCallback<String>() {
                            @Override
                            public void onError(Request request, Exception e) {
                                ErrorBean bean = new ErrorBean();
                                EventBus.getDefault().post(bean);
                            }

                            @Override
                            public void onResponse(String response) {
                                ForunSendBean bean = new Gson().fromJson(response, ForunSendBean.class);
                                EventBus.getDefault().post(bean);
                            }
                        });
                break;
            case 1:
                pairs = new Pair[1];
                pairs[0] = new Pair<>("photo1", files.get(0));
                new OkHttpRequest.Builder()
                        .url("http://115.29.198.151/fzapp/index.php/forumapp/publish")
                        .params(params)
                        .files(pairs)
                        .upload(new ResultCallback<String>() {

                            @Override
                            public void onError(com.squareup.okhttp.Request request, Exception e) {
                                DeviceUtil.Log(e.toString());

                                ErrorBean bean = new ErrorBean();
                                EventBus.getDefault().post(bean);
                            }

                            @Override
                            public void onResponse(String response) {
                                DeviceUtil.Log(response);
                                ForunSendBean bean = new Gson().fromJson(response, ForunSendBean.class);
                                EventBus.getDefault().post(bean);
                            }
                        });
                break;
            case 2:
                DeviceUtil.Log("2");
                pairs = new Pair[2];
                pairs[0] = new Pair<>("photo1", files.get(0));
                pairs[1] = new Pair<>("photo2", files.get(1));
                new OkHttpRequest.Builder()
                        .url("http://115.29.198.151/fzapp/index.php/forumapp/publish")
                        .params(params)
                        .files(pairs)
                        .upload(new ResultCallback<String>() {

                            @Override
                            public void onError(com.squareup.okhttp.Request request, Exception e) {
                                DeviceUtil.Log(e.toString());

                                ErrorBean bean = new ErrorBean();
                                EventBus.getDefault().post(bean);
                            }

                            @Override
                            public void onResponse(String response) {
                                DeviceUtil.Log(response);
                                ForunSendBean bean = new Gson().fromJson(response, ForunSendBean.class);
                                EventBus.getDefault().post(bean);
                            }
                        });
                break;
            case 3:
                DeviceUtil.Log("3");
                pairs = new Pair[3];
                pairs[0] = new Pair<>("photo1", files.get(0));
                pairs[1] = new Pair<>("photo2", files.get(1));
                pairs[2] = new Pair<>("photo3", files.get(2));
                OkHttpRequest.Builder builder = new OkHttpRequest.Builder()
                        .url("http://115.29.198.151/fzapp/index.php/forumapp/publish")
                        .params(params);
                builder.files(pairs);
                builder.upload(new ResultCallback<String>() {

                    @Override
                    public void onError(com.squareup.okhttp.Request request, Exception e) {
                        DeviceUtil.Log(e.toString());
                        ErrorBean bean = new ErrorBean();
                        EventBus.getDefault().post(bean);
                    }

                    @Override
                    public void onResponse(String response) {
                        DeviceUtil.Log("success");
                        ForunSendBean bean = new Gson().fromJson(response, ForunSendBean.class);
                        EventBus.getDefault().post(bean);
                    }
                });
                break;
        }


    }

    @Override
    public void getForum1List(String timeline, String sign, String pagecount, String page, String type) {
        Call call = mServer.getForumList(timeline, sign, pagecount, page, type);
        call.enqueue(new MyCallback<ForumListBean>());
    }

    @Override
    public void getForum2List(String timeline, String sign, String pagecount, String page, String type) {
        Call call = mServer.getForum2List(timeline, sign, pagecount, page, type);
        call.enqueue(new MyCallback<ForumList2Bean>());
    }

    @Override
    public void getReplyList(String timeline, String sign, String pagecount, String page, String userid) {
        Call call = mServer.getReplyList(timeline, sign, pagecount, page, userid);
        call.enqueue(new MyCallback<ForumReplyBean>());
    }

    @Override
    public void getCompanyList2(String timeline, String sign, String value, String userid, String page, String pagecount) {
        Call call = mServer.getCompanyList2(timeline, sign, value, userid, page, pagecount);
        call.enqueue(new MyCallback<CompanyList2Bean>());
    }

    @Override
    public void getProductList2(String timeline, String sign, String value, String userid, String page, String pagecount) {
        Call call = mServer.getProductList2(timeline, sign, value, userid, page, pagecount);
        call.enqueue(new MyCallback<ProductList2Bean>());
    }

    @Override
    public void getFirstMatch(String timeline, String sign) {
        Call call = mServer.getFirstMatch(timeline, sign);
        call.enqueue(new MyCallback<FirstMatchBean>());
    }

    @Override
    public void getFirstReward(String timeline, String sign, String userid) {
        Call call = mServer.getFirstReward(timeline, sign, userid);
        call.enqueue(new MyCallback<FirstRewardBean>());
    }

    @Override
    public void testRule(String timeline, String sign) {
        Call call = mServer.testRule(timeline, sign);
        call.enqueue(new MyCallback<TestRuleBean>());
    }

    @Override
    public void secondRule(String timeline, String sign) {
        Call call = mServer.secondRule(timeline, sign);
        call.enqueue(new MyCallback<SecondRuleBean>());
    }

    @Override
    public void secondTest(String timeline, String sign, String userid) {
        Call call = mServer.secondTest(timeline, sign, userid);
        call.enqueue(new MyCallback<SecondTestBean>());
    }

    @Override
    public void qaappGetCat(String timeline, String sign) {
        Call call = mServer.qaGetCat(timeline, sign);
        call.enqueue(new MyCallback<GetQaCtypeBean>());
    }

    @Override
    public void qaList(String timeline, String sign, String pagecount, String page, String cat) {
        Call call = mServer.qaList(timeline, sign, pagecount, page, cat);
        call.enqueue(new MyCallback<QaListBean>());
    }

    @Override
    public void qaList2(String timeline, String sign, String pagecount, String page, String cat) {
        Call call = mServer.qaList2(timeline, sign, pagecount, page, cat);
        call.enqueue(new MyCallback<QaListBean2>());
    }

    @Override
    public void qaMyList(String timeline, String sign, String pagecount, String page, String userid) {
        Call call = mServer.qaMyList(timeline, sign, pagecount, page, userid);
        call.enqueue(new MyCallback<QaMyListBean>());
    }

    @Override
    public void qaDetail(String timeline, String sign, String id, String pagecount, String page) {
        Call call = mServer.qaDetail(timeline, sign, id, pagecount, page);
        call.enqueue(new MyCallback<QaappDetailBean>());
    }

    @Override
    public void qaCheck(String timeline, String sign, String id, String userid, String answer) {
        Call call = mServer.qaCheck(timeline, sign, id, userid, answer);
        call.enqueue(new MyCallback<QaCheckBean>());
    }

    @Override
    public void qaMyAnswer(String timeline, String sign, String pagecount, String page, String userid) {
        Call call = mServer.qaMyAnswer(timeline, sign, pagecount, page, userid);
        call.enqueue(new MyCallback<QaMyAnswerBean>());
    }

    @Override
    public void qaPublish(String timeline, String sign, String userid, String cat, String score, String content, List<File> files) {
        Map<String, String> params = new HashMap<>();
        params.put("timeline", timeline);
        params.put("sign", sign);
        params.put("userid", userid);
        params.put("cat", cat);
        params.put("score", score);
        params.put("content", content);

        String fileName = "photo";
        Pair<String, File>[] pair = new Pair[files.size()];

        for (int i = 0; i < files.size(); i++) {
            pair[i] = new Pair<>(new StringBuffer(fileName).append(i + 1).toString(), files.get(i));
        }

        OkHttpRequest.Builder builder = new OkHttpRequest.Builder()
                .url("http://115.29.198.151/fzapp/index.php/qaapp/publish")
                .params(params)
                .files(pair);
        builder.upload(new ResultCallback<String>() {

            @Override
            public void onError(com.squareup.okhttp.Request request, Exception e) {
                DeviceUtil.Log(e.toString());
                ErrorBean bean = new ErrorBean();
                EventBus.getDefault().post(bean);
            }

            @Override
            public void onResponse(String response) {
                 DeviceUtil.Log("success" + response);
                QaPublishBean bean = new Gson().fromJson(response, QaPublishBean.class);
                EventBus.getDefault().post(bean);
            }
        });
    }

    @Override
    public void qaUserScore(String timeline, String sign, String userid) {
        Call call = mServer.qaUserScore(timeline, sign, userid);
        call.enqueue(new MyCallback<QaUserScoreBean>());
    }

    @Override
    public void qaAnser(String timeline, String sign, String userid, String id, String content) {
        Call call = mServer.qaAnswer(timeline, sign, userid, id, content);
        call.enqueue(new MyCallback<QaAnswerBean>());
    }

    @Override
    public void matchInvite(String timeline, String sign) {
        Call call = mServer.matchInvite(timeline, sign);
        call.enqueue(new MyCallback<MatchInviteBean>());
    }

    @Override
    public void matchShare(String timeline, String sign, String userid, String testid) {
        Call call = mServer.matchShare(timeline, sign, userid, testid);
        call.enqueue(new MyCallback<MatchShareBean>());
    }

    @Override
    public void qaDelMyQuestion(String timeline, String sign, String userid, String id) {
        Call call = mServer.delMyQuestion(timeline, sign, userid, id);
        call.enqueue(new MyCallback<QaDelMyQuestionBean>());
    }

    @Override
    public void qaDelMyAnswer(String timeline, String sign, String userid, String id) {
        Call call = mServer.delMyAnswer(timeline, sign, userid, id);
        call.enqueue(new MyCallback<QaMyAnswerBean>());
    }

    @Override
    public void getMyForum(String timeline, String sign, String pagecount, String page, String userid) {
        Call call = mServer.getMyForum(timeline, sign, pagecount, page, userid);
        call.enqueue(new MyCallback<MyForumBean>());
    }

    @Override
    public void delMyForum(String timeline, String sign, String userid, String id) {
        Call call = mServer.delForum(timeline, sign, userid, id);
        call.enqueue(new MyCallback<DelForumBean>());
    }

    @Override
    public void forumDetail(String timeline, String sign, String userid, String id, String page) {
        Call call = mServer.forumDetail(timeline, sign, userid, id, page);
        call.enqueue(new MyCallback<ForumDetailBean>());
    }

    @Override
    public void forumUp(String timeline, String sign, String userid, String id, String status) {
        Call  call = mServer.forumUp(timeline, sign, userid, id, status);
        call.enqueue(new MyCallback<ForumUpBean>());
    }

    @Override
    public void forumCollect(String timeline, String sign, String userid, String id, String status) {
        Call call = mServer.forumCollect(timeline, sign, userid, id, status);
        call.enqueue(new MyCallback<ForumCollectBean>());
    }

    @Override
    public void forumComment(String timeline, String sign, String userid, String forumId, String content, String location) {
        Call call = mServer.forumComment(timeline, sign, userid, forumId, content, location);
        call.enqueue(new MyCallback<CommentBean>());
    }

    @Override
    public void reportType(String timeline, String sign) {
        Call call = mServer.reportType(timeline, sign);
        call.enqueue(new MyCallback<ReportTypeBean>());
    }

    @Override
    public void report(String timeline, String sign, String userid, String id, String report) {
        Call call = mServer.report(timeline, sign, userid, id, report);
        call.enqueue(new MyCallback<ReportBean>());
    }

    @Override
    public void society(String timeline, String sign, String pagecount, String page, String userid) {
        Call call = mServer.society(timeline, sign, pagecount, page, userid);
        call.enqueue(new MyCallback<SocietyBean>());
    }

    @Override
    public void societyDetail(String timeline, String sign, String pagecount, String page, String userid, String id) {
        Call call = mServer.societyDetail(timeline, sign, pagecount, page, userid, id);
        call.enqueue(new MyCallback<SocietyDetailBean>());
    }

    @Override
    public void commentReply(String timeline, String sign, String connect_id, String userid, String content) {
        Call call = mServer.commentReply(timeline, sign, connect_id, userid, content);
        call.enqueue(new MyCallback<CommentReplyBean>());
    }

    @Override
    public void forumDel(String timeline, String sign, String userid, String type, String id) {
        Call call = mServer.forumDel(timeline, sign, userid, type, id);
        call.enqueue(new MyCallback<ForumDelBean>());
    }

    @Override
    public void oldFang(String timeline, String sign, String page, String pagecount) {
        Call call = mServer.oldFangList(timeline, sign, page, pagecount);
        call.enqueue(new MyCallback<OldFangBean>());
    }

    @Override
    public void oldFangBanner(String timeline, String sign) {
        Call call = mServer.oldFangBanner(timeline, sign);
        call.enqueue(new MyCallback<OldFangBannerBean>());
    }

    @Override
    public void oldFangDetail(String timeline, String sign, String id, String userid) {
        Call call = mServer.oldFangDetail(timeline, sign, id, userid);
        call.enqueue(new MyCallback<OldFangDetailBean>());
    }

    @Override
    public void oldFangTotal(String timeline, String sign, String id) {
        Call call = mServer.oldFangTotal(timeline, sign, id);
        call.enqueue(new MyCallback<OldFangTotalBean>());
    }

    @Override
    public void oldFangComments(String timeline, String sign, String id, String page, String page_size) {
        Call call = mServer.oldFangComments(timeline, sign, id, page, page_size);
        call.enqueue(new MyCallback<OldFangCommentsBean>());
    }

    @Override
    public void oldFangInsertComment(String timeline, String sign, String id, String userid, String content) {
        Call call = mServer.oldFangInsertComment(timeline, sign, id, userid, content);
        call.enqueue(new MyCallback<OldFangInsertCommentBean>());
    }

    @Override
    public void oldFangFavorite(String timeline, String sign, String aid, String userid) {
        Call call = mServer.oldFangFavorite(timeline, sign, aid, userid);
        call.enqueue(new MyCallback<OldFangFavoriteBean>());
    }

    @Override
    public void getShopList(String timeline, String sign, String pagecount, String per, String userid) {
        Call call = mServer.getShopList(timeline, sign, pagecount, per, userid);
        call.enqueue(new MyCallback<ShopListBean>());
    }

    @Override
    public void getScoreList(String timeline, String sign, String userid, String page) {
        Call call = mServer.getScoreList(timeline, sign, userid, page);
        call.enqueue(new MyCallback<ScoreListBean>());
    }

    @Override
    public void getExChargeList(String timeline, String sign, String userid, String page) {
        Call call = mServer.getExChangeList(timeline, sign, userid, page);
        call.enqueue(new MyCallback<ExChangeListBean>());
    }

    @Override
    public void getExcharge(String timeline, String sign, String userid, String id, String name, String tel, String address) {
        Call call = mServer.getExcharge(timeline, sign, userid, id, name, tel, address);
        call.enqueue(new MyCallback<ExchargeBean>());
    }

    @Override
    public void getVersion(String timeline, String sign) {
        Call call = mServer.getVersion(timeline, sign);
        call.enqueue(new MyCallback<VersionBean>());
    }

    @Override
    public void secondTime(String timeline, String sign) {
        Call call = mServer.secondTime(timeline, sign);
        call.enqueue(new MyCallback<SecondTimeBean>());
    }

    @Override
    public void secondDownload(String timeline, String sign) {
        Call call = mServer.secondDownload(timeline, sign);
        call.enqueue(new Callback<SecondDownloadBean>() {
            @Override
            public void onResponse(Response response, Retrofit retrofit) {

            }

            @Override
            public void onFailure(Throwable t) {

            }
        });
    }


    @Override
    public void secondHandle1(String timeline, String sign, String userid, String start, String score, String testid) {
        Call call = mServer.secondHandle1(timeline, sign, userid, start, score, testid);
        call.enqueue(new MyCallback<FinishExamBean>());
    }

    @Override
    public void signStatus(String timeline, String sign, String userid) {
        Call call = mServer.signStatus(timeline, sign, userid);
        call.enqueue(new MyCallback<SignStatusBean>());
    }

    @Override
    public void secondEnter(String timeline, String sign, String userid) {
        Call call = mServer.secondEnter(timeline, sign, userid);
        call.enqueue(new MyCallback<SecondEnterBean>());
    }

    @Override
    public void myClassNew(String timeline, String sign, String userid) {
        Call call = mServer.myClassNew(timeline, sign, userid);
        call.enqueue(new MyCallback<MyClassNewBean>());
    }

    @Override
    public void secondTimeJudge(String timeline, String sign) {
        Call call = mServer.secondTimeJudge(timeline, sign);
        call.enqueue(new MyCallback<SecondTimeJudgeBean>());
    }
}
